<template>
	<div class="mybox">
			<h3 style="margin:20px auto 40px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;跨部门调职申请</h3>
			<el-form class="infro" label-width="100px" label="调职申请">
				<el-form-item label="员工编号  :">
					<el-input v-model="me.eid" autocoplete="off" disabled></el-input>
				</el-form-item>
				<el-form-item label="姓    名  :">
					<el-input v-model="me.ename" autocoplete="off" disabled></el-input>
				</el-form-item>
				<el-form-item label="当前部门  :">
					<el-input v-model="me.dname" autocoplete="off" disabled></el-input>
				</el-form-item>
				<el-form-item label="申请时间  :">
					<el-input v-model="now" autocoplete="off" disabled></el-input>
				</el-form-item>
				<el-form-item label="调入部门  :">
					<el-select v-model="pickdept" placeholder="请选择" @change="checkdept">
						<el-option
							v-for="item in depts"
							v-if="item.deptno!=me.deptno"
							:key="item.deptno"
							:label="item.dname"
							:value="item.deptno">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-input type="hidden"/>
				</el-form-item>
				<br/>
				<el-form-item label="申请备注  :">
					<el-input type="textarea" v-model="infro" autocoplete="off" style="width:530px"></el-input>
				</el-form-item>
				<br/>
				<br/>
				<el-button type="success" @click="sureChange" :disabled="disable">提交</el-button>
			</el-form>
		</div>
	</template>
	
	<script>
		export default {
			data() {
				return {
					me:this.$parent.$parent.$parent.$parent.emp,
					now:new Date().toLocaleDateString(),
					pickdept:'',
					depts:[],
					infro:'',
					disable:true,
				};
			},
			created(){
				this.$axios.post("showtransfer").then(v=>{
					console.log(v)
					if(v.data){
						this.depts=v.data;
					}else{
						this.$message.error("出错了！！")
						//alert("出错了！！");
					}
				}).catch(ex=>{
					this.$message.error("出错了！！"+ex)
					//alert("出错了！"+ex);
				})
			},
			methods:{			
				sureChange(){
					 this.$confirm(
						"你确定提交吗？",
						"温馨提示",
						{
								confirmButtonText:'确定',
								cancelButtonText:'取消',
								type:'warning'
						}
					).then(()=>{
						
						this.$axios.post("transfer?eid="+this.me.eid+"&predno="+this.me.deptno+"&subdno="+this.pickdept+"&changeDate="+this.now+"&infro="+this.infro+"").then(v=>{
							console.log(v)
							if(v.data){
								this.$message({
									type:"success",
									message:"提交成功！"
								}); 
								this.$router.push("/home/");
							}else{
								this.$message.error("出错了！！")
							}
						}).catch(ex=>{
							this.$message.error("出错了！！"+ex)
						})
					}).catch(()=>{
						this.$message({
							type:"info",
							message:"你已经取消"
						});
					}) 
					
				},
				checkdept(){
					this.disable=true;
					if(this.pickdept!=''){
						this.disable=false;
					}
				}
			}
		}
	</script>

<style>
.mybox{
		width:900px;
		height:600px;
		border:1px solid #FFFFFF;
		background:#FFFFFF;
	}
	.mybox .infro .el-form{
		margin:0 auto;
		width:900px;
	}
	.mybox .el-input{
		width:200px;
		float:left;
	}
	.mybox .infro .el-form-item{
		display:inline-block;
	}
	.infro .el-form-item{
		text-align: center;
	}
	.infro .el-input{
		width:210px;
	}
</style>
